const express = require('express');
const cookieParser = require('cookie-parser');

const server = express();

// cookie加密
server.use(cookieParser('adg434yhar'));

server.use('/', (req, res) => {
    req.secret = 'adg434yhar'
    res.cookie('user', 'blue', {
        signed: true
    });
    res.cookie('age', '40');
    // 签名cookie
    console.log('签名cookie', req.signedCookies);

    // 无签名cookie
    console.log('无签名cookie', req.cookies);
    res.send('ok');
});

server.listen(8080, () => {
    console.log('服务启动成功!');
});

